fix: reject passwords longer than 72 bytes#449
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR implements server-side password length validation across GoTrue's API endpoints. It introduces a 72-byte maximum password length limit at the model layer through a new Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions Comment |
…d-length-maximum-bcrypt-72-byte
…d-length-maximum-bcrypt-72-byte
…d-length-maximum-bcrypt-72-byte
…d-length-maximum-bcrypt-72-byte
…d-length-maximum-bcrypt-72-byte
…d-length-maximum-bcrypt-72-byte
- Summary
bcrypt.GenerateFromPasswordsilently truncates its input at 72 bytes, so a 200-character password only had its first 72 bytes verified on sign-in. This rejects passwords longer than 72 bytes at the API layer with a 422, and at the model layer (ErrPasswordTooLong) as defense in depth for non-HTTP callers like the CLI admin tool. The error message says "bytes" on purpose since CJK characters and emoji are multi-byte in UTF-8, and existing users with previously-truncated stored hashes keep signing in fine becausebcrypt.CompareHashAndPasswordalso truncates.- Test plan
- Description for the changelog
Reject passwords longer than 72 bytes (the bcrypt input limit) with a 422.
- A picture of a cute animal (not mandatory but encouraged)